#ifndef ACTIONTHREAD_H
#define ACTIONTHREAD_H

#include <QThread>
#include <QTcpSocket>
#include "UserManager.h"

class ActionThread : public QThread
{
	Q_OBJECT

	enum CommandType{
		Register,
		Hello,
		AccountData,
		SetStatus,
		UsersList,
		GetUserData,
		Message,
		Message2,
		SendFile,
		FileSubmit,
		FileReady,
		FileTransmit,
		GetFile
	};

	UserManager* _userManager;

public:
	ActionThread(int socketDescriptor, UserManager* userManager, QObject *parent);

	void run();

signals:
	void error(QTcpSocket::SocketError socketError);

	void writeData(QString data);

private:
	int _socketDescriptor;
	QTcpSocket _socket;

	void sendData(QByteArray data);

public slots:
	void onBytesReady();
	void onDisconnected();
};

#endif // ACTIONTHREAD_H
